# $Id: PKGBUILD 177517 2013-02-06 16:18:02Z foutrelis $
# Maintainer: Evangelos Foutras <evangelos@foutrelis.com>

pkgname=geoip-database
pkgver=20130206
pkgrel=1
pkgdesc="GeoLite country geolocation database compiled by MaxMind"
arch=('any')
url="http://www.maxmind.com/app/ip-location"
license=('custom:OPEN DATA LICENSE')
source=(GeoIP-$pkgver.dat.gz::http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
        GeoIPv6-$pkgver.dat.gz::http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz
        http://geolite.maxmind.com/download/geoip/database/LICENSE.txt)
noextract=(GeoIP-$pkgver.dat.gz
           GeoIPv6-$pkgver.dat.gz)
sha256sums=('8bce6035e9c56d11dd69244d37aeeeadb632b0c4b9027eb0d93edff9804fcdb5'
            '7e797d906c36906e7a27136c477b6540579c17ada9b8a604a9bad711369875ae'
            '83a4cb82ef8953c0107886b49bc39fcf77590a222d30e778d48f5d92f5b5e383')

build() {
  cd "$srcdir"

  for _database_name in GeoIP GeoIPv6; do
    gunzip -c $_database_name-$pkgver.dat.gz >$_database_name.dat
  done
}

check() {
  cd "$srcdir"

  for _database in {GeoIP,GeoIPv6}.dat; do
    if ! grep -q 'MaxMind Inc All Rights Reserved' $_database; then
      error "Copyright notice is missing from $_database; something is fishy!"
      return 1
    fi
  done
}

package() {
  cd "$srcdir"

  install -d "$pkgdir/usr/share/GeoIP"
  install -m644 -t "$pkgdir/usr/share/GeoIP" GeoIP.dat GeoIPv6.dat

  install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE.txt"
}

# vim:set ts=2 sw=2 et:
